package com.apes.hr.cultivate.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.api.SpringManager;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.framework.util.DateUtil;
import com.apes.hr.base.model.Employee;
import com.apes.hr.base.model.Job;
import com.apes.hr.base.model.Rank;
import com.apes.hr.base.model.WorkPost;
import com.apes.scm.masterdata.frame.model.Branch;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 培训计划 考核
 * @author Linwz
 * @create 2019-06-18 10:11
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CultivatePlanAppraisalItem.CONST_TABLE_NAME)
public class CultivatePlanAppraisalItem extends Model {
    public static final String CONST_TABLE_NAME = "hr_appraisal_item";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "培训计划考核明细")
    @Comment("培训计划考核明细编码")
    private String id;   //培训计划考核明细编码

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "cultivate_plan_appraisal_id", referencedColumnName = "ID")
    @Comment("培训计划考核")
    private CultivatePlanAppraisal cultivatePlanAppraisal; //培训计划考核


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "employee_id", referencedColumnName = "id")
    @Comment("人员编码")
    private Employee employeeId; //人员编码

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "branch_id", referencedColumnName = "id")
    @Comment("部门")
    private Branch branch; // 部门

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "job_id", referencedColumnName = "id")
    @Comment("职位")
    private Job job; //职位

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "post_id", referencedColumnName = "id")
    @Comment("岗位")
    private WorkPost workPost; // 岗位

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "rank_id", referencedColumnName = "id")
    @Comment("职级")
    private Rank rankId; // 职级

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "entry_date")
    @Comment("入职日期")
    private Date entryDate;  //入职日期

    @Column(name = "duration")
    @Comment("入职时长")
    private int duration;//入职时长

    @Column(name = "success")
    @Comment("成绩")
    private int success;//成绩

    @Column(name = "course_level", length = 16)
    @Comment("等级")
    private String courseLevel;   //等级

    @Column(name = "evaluate", length = 4000)
    @Comment("培训评价")
    private String evaluate;   //培训评价


    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "serve_state_date")
    @Comment("约定培训服务期起")
    private Date serveStateDate;  //约定培训服务期起

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "serve_end_date")
    @Comment("约定培训服务期止")
    private Date serveEndDate;  //约定培训服务期止


    @Column(name = "participate_status", length = 30)
    @Comment("参加状况")
    private String participateStatus = "0"; //参加状况

    @Column(name = "note", length = 1000)
    @Comment("备注")
    private String note;   //备注

}
